<template>
  <div>
    <ul v-for="item in arr" :key="item.id">
      <li>
        {{ item.number }}
        <button @click="del(item.id)">删除</button>
      </li>
    </ul>
    <button @click="aa">添加</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      arr: [],
    };
  },
  methods: {
    aa() {
      this.arr.push({
        id: +new Date(),
        number: Math.floor(Math.random() * 20),
      });
    },
    del(id){
      this.arr=this.arr.filter((item)=>item.id!==id)
    }
  },
};
</script>

<style>
</style>
